package phone.example.com.a36kr.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import phone.example.com.a36kr.R;
import phone.example.com.a36kr.bean.PopWindowBean;
import phone.example.com.a36kr.nettool.NetTool;
import phone.example.com.a36kr.tools.MyApp;

/**
 * Created by dllo on 16/8/25.
 */
public class PopWindowLvAdapter extends BaseAdapter{

    private Context context;
    private PopWindowBean popWindowBeen;
    private int feedId;

    public int getFeedId() {
        return feedId;
    }

    public PopWindowLvAdapter(Context context) {
        this.context = context;
    }

    public void setPopWindowBeen(PopWindowBean popWindowBeen) {
        this.popWindowBeen = popWindowBeen;
    }

    @Override
    public int getCount() {
        return popWindowBeen != null ? popWindowBeen.getData().getLatestArticle().size() : 0;
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        convertView = LayoutInflater.from(context).inflate(R.layout.items_pop_window_second,null);

        NetTool mNetTool = new NetTool();
        ImageView popIm = (ImageView) convertView.findViewById(R.id.items_pop_im);
        mNetTool.getImage(popWindowBeen.getData().getLatestArticle().get(position).getFeatureImg(),popIm);
        TextView popTv = (TextView) convertView.findViewById(R.id.items_pop_title );
        popTv.setText(popWindowBeen.getData().getLatestArticle().get(position).getTitle());
        feedId = popWindowBeen.getData().getLatestArticle().get(position).getPostId();

        return convertView;
    }
}
